﻿using System;
using System.Data;
using System.Windows.Forms;

namespace ProjectStudent
{
    public partial class UserEditForm : Form
    {
        public int UserId { get; set; }
        //public UserEditForm()
        //{
        //    InitializeComponent();
        //}
        public UserEditForm(DataRow row)  
        {
            InitializeComponent();
            if (row != null)
            {
                this.Text = "修改";
                UserId = Convert.ToInt32(row["Id"]);
                txtUserName.Text = row["Name"].ToString().Trim();
                txtUserPassword.Text = row["Password"].ToString();
                dtpCreateDate.Value = Convert.ToDateTime(row["time"]);

            }
            else
            {
                this.Text = "新增";
            }
        }

        public string UserName => txtUserName.Text.Trim();
        public string Password => txtUserPassword.Text.Trim();
        public DateTime time => dtpCreateDate.Value;

        public void btnEdit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(Password))
            {
                MessageBox.Show("用户名和密码不能为空！");
                return;
            }
            this.DialogResult = DialogResult.OK;

        }
    }
}
